﻿Imports System.Data
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class Login

    Dim objConn As OracleConnection
    Public strConn As String
    Dim id As String
    Dim Pass As String


    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim User As String        
        If UserText.Text <> "" And PassText.Text <> "" Then
            id = UserText.Text
            Pass = PassText.Text
            strConn = "Data Source=LOCALHOST/orcl;User Id=" + id + ";Password=" + Pass + ";"
            objConn = New OracleConnection(strConn)
            Try
            objConn.Open()
            If objConn.State = ConnectionState.Open Then
                Me.Hide()
                Form2.Show()
            End If
            Catch ex As Exception
                MsgBox("ID หรือ Password ผิดพลาด")
                MsgBox("ไม่สามารถ connect ฐานข้อมูลได้")
            End Try
        ElseIf UserText.Text = "" Then
            User = "Please Enter Username"
            MessageBox.Show(User)
        ElseIf PassText.Text = "" Then
            User = "Please Enter Password"
            MessageBox.Show(User)
        End If
        PassText.Text = ""
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

    Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
End Class
